package com.hoyue.dao.impl;

import java.sql.SQLException;

import java.util.List;

import com.hoyue.bean.Video;
import com.hoyue.dao.VideoDao;
import com.hoyue.utils.C3P0Utils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

public class VideoDaoImpl implements VideoDao{
    QueryRunner qr = C3P0Utils.getQueryRunner();

    @Override
    public void updateVideo(Video video) throws SQLException {
        String sql = "update video set title = ? , Presentation = ? , Address = ? where id = ?";

        qr.update(sql,video.getTitle(),video.getPresentation(),video.getAddress(),video.getId());
    }

    @Override
    public Video getVideo() throws SQLException {
        String sql = "select * from video";

        return qr.query(sql, new BeanHandler<>(Video.class));
    }
}